(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^2).


The TRS R consists of the following rules:

sort#2(Nil) → Nil
sort#2(Cons(x4, x2)) → insert#3(x4, sort#2(x2))
cond_insert_ord_x_ys_1(True, x3, x2, x1) → Cons(x3, Cons(x2, x1))
cond_insert_ord_x_ys_1(False, x3, x2, x1) → Cons(x2, insert#3(x3, x1))
insert#3(x2, Nil) → Cons(x2, Nil)
insert#3(x6, Cons(x4, x2)) → cond_insert_ord_x_ys_1(leq#2(x6, x4), x6, x4, x2)
leq#2(0, x8) → True
leq#2(S(x12), 0) → False
leq#2(S(x4), S(x2)) → leq#2(x4, x2)
main(x1) → sort#2(x1)

Rewrite Strategy: INNERMOST

(1) CpxTrsToCdtProof (BOTH BOUNDS(ID, ID) transformation)

Converted Cpx (relative) TRS to CDT

(2) Obligation:

Complexity Dependency Tuples Problem
Rules:

sort#2(Nil) → Nil
sort#2(Cons(z0, z1)) → insert#3(z0, sort#2(z1))
cond_insert_ord_x_ys_1(True, z0, z1, z2) → Cons(z0, Cons(z1, z2))
cond_insert_ord_x_ys_1(False, z0, z1, z2) → Cons(z1, insert#3(z0, z2))
insert#3(z0, Nil) → Cons(z0, Nil)
insert#3(z0, Cons(z1, z2)) → cond_insert_ord_x_ys_1(leq#2(z0, z1), z0, z1, z2)
leq#2(0, z0) → True
leq#2(S(z0), 0) → False
leq#2(S(z0), S(z1)) → leq#2(z0, z1)
main(z0) → sort#2(z0)
Tuples:

SORT#2(Nil) → c
SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
COND_INSERT_ORD_X_YS_1(True, z0, z1, z2) → c2
COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
INSERT#3(z0, Nil) → c4
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(0, z0) → c6
LEQ#2(S(z0), 0) → c7
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
MAIN(z0) → c9(SORT#2(z0))
S tuples:

SORT#2(Nil) → c
SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
COND_INSERT_ORD_X_YS_1(True, z0, z1, z2) → c2
COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
INSERT#3(z0, Nil) → c4
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(0, z0) → c6
LEQ#2(S(z0), 0) → c7
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
MAIN(z0) → c9(SORT#2(z0))
K tuples:none
Defined Rule Symbols:

sort#2, cond_insert_ord_x_ys_1, insert#3, leq#2, main

Defined Pair Symbols:

SORT#2, COND_INSERT_ORD_X_YS_1, INSERT#3, LEQ#2, MAIN

Compound Symbols:

c, c1, c2, c3, c4, c5, c6, c7, c8, c9

(3) CdtLeafRemovalProof (ComplexityIfPolyImplication transformation)

Removed 1 leading nodes:

MAIN(z0) → c9(SORT#2(z0))
Removed 5 trailing nodes:

LEQ#2(S(z0), 0) → c7
SORT#2(Nil) → c
LEQ#2(0, z0) → c6
INSERT#3(z0, Nil) → c4
COND_INSERT_ORD_X_YS_1(True, z0, z1, z2) → c2

(4) Obligation:

Complexity Dependency Tuples Problem
Rules:

sort#2(Nil) → Nil
sort#2(Cons(z0, z1)) → insert#3(z0, sort#2(z1))
cond_insert_ord_x_ys_1(True, z0, z1, z2) → Cons(z0, Cons(z1, z2))
cond_insert_ord_x_ys_1(False, z0, z1, z2) → Cons(z1, insert#3(z0, z2))
insert#3(z0, Nil) → Cons(z0, Nil)
insert#3(z0, Cons(z1, z2)) → cond_insert_ord_x_ys_1(leq#2(z0, z1), z0, z1, z2)
leq#2(0, z0) → True
leq#2(S(z0), 0) → False
leq#2(S(z0), S(z1)) → leq#2(z0, z1)
main(z0) → sort#2(z0)
Tuples:

SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
S tuples:

SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
K tuples:none
Defined Rule Symbols:

sort#2, cond_insert_ord_x_ys_1, insert#3, leq#2, main

Defined Pair Symbols:

SORT#2, COND_INSERT_ORD_X_YS_1, INSERT#3, LEQ#2

Compound Symbols:

c1, c3, c5, c8

(5) CdtUsableRulesProof (EQUIVALENT transformation)

The following rules are not usable and were removed:

main(z0) → sort#2(z0)

(6) Obligation:

Complexity Dependency Tuples Problem
Rules:

sort#2(Nil) → Nil
sort#2(Cons(z0, z1)) → insert#3(z0, sort#2(z1))
insert#3(z0, Nil) → Cons(z0, Nil)
insert#3(z0, Cons(z1, z2)) → cond_insert_ord_x_ys_1(leq#2(z0, z1), z0, z1, z2)
cond_insert_ord_x_ys_1(True, z0, z1, z2) → Cons(z0, Cons(z1, z2))
cond_insert_ord_x_ys_1(False, z0, z1, z2) → Cons(z1, insert#3(z0, z2))
leq#2(0, z0) → True
leq#2(S(z0), 0) → False
leq#2(S(z0), S(z1)) → leq#2(z0, z1)
Tuples:

SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
S tuples:

SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
K tuples:none
Defined Rule Symbols:

sort#2, insert#3, cond_insert_ord_x_ys_1, leq#2

Defined Pair Symbols:

SORT#2, COND_INSERT_ORD_X_YS_1, INSERT#3, LEQ#2

Compound Symbols:

c1, c3, c5, c8

(7) CdtRuleRemovalProof (UPPER BOUND(ADD(n^1)) transformation)

Found a reduction pair which oriented the following tuples strictly. Hence they can be removed from S.

SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
We considered the (Usable) Rules:none
And the Tuples:

SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
The order we found is given by the following interpretation:
Polynomial interpretation :

POL(0) = 0   
POL(COND_INSERT_ORD_X_YS_1(x1, x2, x3, x4)) = 0   
POL(Cons(x1, x2)) = [1] + x2   
POL(False) = 0   
POL(INSERT#3(x1, x2)) = 0   
POL(LEQ#2(x1, x2)) = 0   
POL(Nil) = 0   
POL(S(x1)) = 0   
POL(SORT#2(x1)) = x1   
POL(True) = 0   
POL(c1(x1, x2)) = x1 + x2   
POL(c3(x1)) = x1   
POL(c5(x1, x2)) = x1 + x2   
POL(c8(x1)) = x1   
POL(cond_insert_ord_x_ys_1(x1, x2, x3, x4)) = 0   
POL(insert#3(x1, x2)) = 0   
POL(leq#2(x1, x2)) = 0   
POL(sort#2(x1)) = 0   

(8) Obligation:

Complexity Dependency Tuples Problem
Rules:

sort#2(Nil) → Nil
sort#2(Cons(z0, z1)) → insert#3(z0, sort#2(z1))
insert#3(z0, Nil) → Cons(z0, Nil)
insert#3(z0, Cons(z1, z2)) → cond_insert_ord_x_ys_1(leq#2(z0, z1), z0, z1, z2)
cond_insert_ord_x_ys_1(True, z0, z1, z2) → Cons(z0, Cons(z1, z2))
cond_insert_ord_x_ys_1(False, z0, z1, z2) → Cons(z1, insert#3(z0, z2))
leq#2(0, z0) → True
leq#2(S(z0), 0) → False
leq#2(S(z0), S(z1)) → leq#2(z0, z1)
Tuples:

SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
S tuples:

COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
K tuples:

SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
Defined Rule Symbols:

sort#2, insert#3, cond_insert_ord_x_ys_1, leq#2

Defined Pair Symbols:

SORT#2, COND_INSERT_ORD_X_YS_1, INSERT#3, LEQ#2

Compound Symbols:

c1, c3, c5, c8

(9) CdtRuleRemovalProof (UPPER BOUND(ADD(n^2)) transformation)

Found a reduction pair which oriented the following tuples strictly. Hence they can be removed from S.

INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
We considered the (Usable) Rules:

insert#3(z0, Nil) → Cons(z0, Nil)
cond_insert_ord_x_ys_1(True, z0, z1, z2) → Cons(z0, Cons(z1, z2))
cond_insert_ord_x_ys_1(False, z0, z1, z2) → Cons(z1, insert#3(z0, z2))
sort#2(Cons(z0, z1)) → insert#3(z0, sort#2(z1))
sort#2(Nil) → Nil
insert#3(z0, Cons(z1, z2)) → cond_insert_ord_x_ys_1(leq#2(z0, z1), z0, z1, z2)
And the Tuples:

SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
The order we found is given by the following interpretation:
Polynomial interpretation :

POL(0) = [2]   
POL(COND_INSERT_ORD_X_YS_1(x1, x2, x3, x4)) = x4   
POL(Cons(x1, x2)) = [1] + x1 + x2   
POL(False) = 0   
POL(INSERT#3(x1, x2)) = x2   
POL(LEQ#2(x1, x2)) = x2   
POL(Nil) = [1]   
POL(S(x1)) = [2] + x1   
POL(SORT#2(x1)) = [2]x1 + [2]x12   
POL(True) = 0   
POL(c1(x1, x2)) = x1 + x2   
POL(c3(x1)) = x1   
POL(c5(x1, x2)) = x1 + x2   
POL(c8(x1)) = x1   
POL(cond_insert_ord_x_ys_1(x1, x2, x3, x4)) = [2] + [2]x2 + x3 + x4   
POL(insert#3(x1, x2)) = [1] + [2]x1 + x2   
POL(leq#2(x1, x2)) = 0   
POL(sort#2(x1)) = [2]x1   

(10) Obligation:

Complexity Dependency Tuples Problem
Rules:

sort#2(Nil) → Nil
sort#2(Cons(z0, z1)) → insert#3(z0, sort#2(z1))
insert#3(z0, Nil) → Cons(z0, Nil)
insert#3(z0, Cons(z1, z2)) → cond_insert_ord_x_ys_1(leq#2(z0, z1), z0, z1, z2)
cond_insert_ord_x_ys_1(True, z0, z1, z2) → Cons(z0, Cons(z1, z2))
cond_insert_ord_x_ys_1(False, z0, z1, z2) → Cons(z1, insert#3(z0, z2))
leq#2(0, z0) → True
leq#2(S(z0), 0) → False
leq#2(S(z0), S(z1)) → leq#2(z0, z1)
Tuples:

SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
S tuples:

COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
K tuples:

SORT#2(Cons(z0, z1)) → c1(INSERT#3(z0, sort#2(z1)), SORT#2(z1))
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
LEQ#2(S(z0), S(z1)) → c8(LEQ#2(z0, z1))
Defined Rule Symbols:

sort#2, insert#3, cond_insert_ord_x_ys_1, leq#2

Defined Pair Symbols:

SORT#2, COND_INSERT_ORD_X_YS_1, INSERT#3, LEQ#2

Compound Symbols:

c1, c3, c5, c8

(11) CdtKnowledgeProof (EQUIVALENT transformation)

The following tuples could be moved from S to K by knowledge propagation:

COND_INSERT_ORD_X_YS_1(False, z0, z1, z2) → c3(INSERT#3(z0, z2))
INSERT#3(z0, Cons(z1, z2)) → c5(COND_INSERT_ORD_X_YS_1(leq#2(z0, z1), z0, z1, z2), LEQ#2(z0, z1))
Now S is empty

(12) BOUNDS(1, 1)